home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 15 code / Floating Windows / Floating Windows Code / Shell Code / fileMenuRoutines.c < prev    next >
Encoding:
Text File  |  1995-06-23  |  2.6 KB  |  109 lines  |  [TEXT/MMCC]

  1. // If the interfaces aren't included yet, do the standard includes. Otherwise, precompiled headers
  2. // have been loaded already, thank you very much
  3. #ifndef __TYPES__
  4.     #include <Types.h>
  5.     #include <AppleEvents.h>
  6.     #include <Desk.h>
  7.     #include <Dialogs.h>
  8.     #include <Editions.h>
  9.     #include <Events.h>
  10.     #include <Menus.h>
  11.     #include <SegLoad.h>
  12.     #include <StandardFile.h>
  13.     #include <TextUtils.h>
  14.     #include <ToolUtils.h>
  15.     #include <Windows.h>
  16. #endif
  17.  
  18. #include "fileMenuRoutines.h"
  19. #include "WindowExtensions.h"
  20.  
  21.     /* Temporary defines */
  22.     
  23. #define    rAlertStringsID    129
  24. #define    kOpenFileString        1
  25. #define    kPrintFileString    2
  26. #define    kNotificationString    3
  27.  
  28.     /*    Private prototypes */
  29.     
  30. void    AlertUser(short alertStringID, Str255 fileName);
  31.  
  32. // Globals
  33. extern Boolean    gInBackground;                    /* Set to true if app is switched into background */
  34. extern Boolean    gNotificationPosted;            // True if a notification was posted
  35. extern NMRec    gNotificationRec;                // the notification record
  36. Str255            gErrString;
  37.     
  38. void    AlertUser(short    alertStringID, Str255 fileName)
  39. {
  40.     short    alrtItem;
  41.     
  42.     // dkj 4/95 changed to use notification manager if not in front
  43.     if(gInBackground)
  44.     {
  45.         if(gNotificationPosted == false)
  46.         {
  47.             // Get nifty notification string
  48.             GetIndString(gErrString, rAlertStringsID, kNotificationString);
  49.             
  50.             // The WRONG way for an app to do it (just putting up an alert), but useful for testing
  51.             gNotificationRec.qType = nmType;        // Notification queue
  52.             gNotificationRec.nmMark = 0;            // no mark in app menu
  53.             gNotificationRec.nmIcon = nil;            // no Icon
  54.             gNotificationRec.nmSound = (Handle)-1;    // system alert sound
  55.             gNotificationRec.nmStr = gErrString;    // The meat of the matter
  56.             gNotificationRec.nmResp = nil;            // No response proc
  57.             gNotificationRec.nmRefCon = nil;        // No refcon
  58.             
  59.             NMInstall(&gNotificationRec);
  60.             gNotificationPosted = true;
  61.         }
  62.     }
  63.     else
  64.     {
  65.         DeactivateFloatersAndFirstDocumentWindow();
  66.         GetIndString(gErrString, rAlertStringsID, alertStringID);
  67.         ParamText(gErrString, fileName, nil, nil);
  68.         alrtItem = Alert(129, nil);
  69.         ActivateFloatersAndFirstDocumentWindow();
  70.     }
  71. }
  72.  
  73. void    GetFileToOpen()
  74.  
  75. /*    Have user choose a file to open from StandardGetFile */
  76.  
  77. {
  78.     StandardFileReply    fileInfo;
  79.     SFTypeList            typesToShow;
  80.     
  81.     typesToShow[0] = '****';
  82.     
  83.     DeactivateFloatersAndFirstDocumentWindow();
  84.     StandardGetFile(nil, -1, typesToShow, &fileInfo);
  85.     
  86.     if (fileInfo.sfGood)
  87.         DoOpenFile(&(fileInfo.sfFile));
  88.     
  89.     ActivateFloatersAndFirstDocumentWindow();
  90. }
  91.  
  92. void    DoOpenFile(FSSpec *fileToOpen)
  93.  
  94. {
  95.     AlertUser(kOpenFileString, fileToOpen->name);
  96. }
  97.  
  98. void    DoPrint()
  99.  
  100. {
  101. }
  102.  
  103. void    DoPrintFile(FSSpec *fileToPrint)
  104.  
  105. {
  106.     AlertUser(kPrintFileString, fileToPrint->name);
  107. }
  108.  
  109.